<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Aloha Editor command underline tests</title>
	<!-- include qunit -->
	<link rel="stylesheet" href="../../vendor/qunit.css" type="text/css"/>

	<script type="text/javascript" src="../../vendor/qunit.js"></script>

	<script src="../../../lib/require.js" ></script>
	<!-- include jquery -->
	<script	src="../../../lib/vendor/jquery-3.7.0.js" ></script>
	<script type="text/javascript" src="../../vendor/jquery.simulate.js"></script>
	<script>
        require.config({
		    baseUrl: "../"
        });
		var Aloha = {
			settings: {
				jQuery: $,
				baseUrl: '../../../lib'
			}
		};
	</script>

	<!-- include aloha -->
	<script src="../../../lib/aloha.js" ></script>

	<script>
		// load command test suite
		require( ['commandtest'] );
	</script>
	<style type="text/css">
		.aloha-editable ol li { list-style-type: decimal; margin: 1.5em; }
		.aloha-editable ol li ol li{ list-style-type: decimal; margin: 2em; }
	</style>
	<link rel="stylesheet" href="../commandtest.css" type="text/css"/>
</head>
<body>
	<!-- include the tests -->
	<script>
	var tests = {
			defaultValue: '',
			defaultCommand: 'underline',
			defaultAttributes: [ 'underline' ],
			tests: [		        
					{  	start: 'fo[o<u>b]ar</u>baz',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'foo<u>ba[r</u>b]az',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'fo[o<u>bar</u>b]az',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'foo[<u>b]ar</u>baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo<u>ba[r</u>]baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo[<u>bar</u>]baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo<u>[bar]</u>baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo{<u>bar</u>}baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'fo[o<span style=text-decoration:underline>b]ar</span>baz',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: "foo[]bar",
              execResult: "foo[]bar"
          },
					{  	start: "<p>[foo</p><p>bar]</p>",
              execResult: "<p><u>[foo</u></p><p><u>bar]</u></p>"
          },
					{  	start: "<span>[foo</span><span>bar]</span>",
              execResult: "<u><span>[foo</span><span>bar]</span></u>"
          },
					{  	start: "<p>[foo</p><p><span>bar</span></p><p>baz]</p>",
              execResult: "<p><u>[foo</u></p><p><u><span>bar</span></u></p><p><u>baz]</u></p>"
          },
          {   exclude: ['msie7.0', 'msie8.0'], //inserts an extra whitespace in the middle of the result
					  	start: "<p>[foo<p><br><p>bar]",
              execResult: "<p><u>[foo</u></p><p><u><br></u></p><p><u>bar]</u></p>"
          },
          {   exclude: ['webkit', 'msie7.0', 'msie8.0'],	
					  	start: "<span>foo</span>{}<span>bar</span>",
              execResult: "<span>foo</span>{}<span>bar</span>"
          },
          {   include: ['webkit', 'msie7.0', 'msie8.0'],	
					  	start: "<span>foo</span>{}<span>bar</span>",
              execResult: "<span>foo[]</span><span>bar</span>"
          },
          // Note: Following test also fails to run on IE9.
          {   exclude: ['webkit', 'msie'], 	
					  	start: "<span>foo[</span><span>]bar</span>",
              execResult: "<span>foo[</span><span>]bar</span>"
          },
					{  	start: "foo[bar]baz",
              execResult: "foo<u>[bar]</u>baz"
          },
					{  	start: "foo[bar<b>baz]qoz</b>quz",
              execResult: "foo<u>[bar</u><b><u>baz]</u>qoz</b>quz"
          },
					{  	start: "foo[bar<i>baz]qoz</i>quz",
              execResult: "foo<u>[bar</u><i><u>baz]</u>qoz</i>quz"
          },
          {   exclude: ['webkit', 'msie7.0', 'msie8.0'], //cursor selection is wrong	
              start: "{<p><p><p>foo</p>}",
              execResult: "{<p></p><p></p><p><u>foo</u></p>}"
          },
          {   exclude: ['msie7.0', 'msie8.0'], //adds extra whitespaces in the result
              start: "<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>",
              execResult: "<table><tbody><tr><td>foo</td><td>b<u>[a]</u>r</td><td>baz</td></tr></tbody></table>"
          },
          {   exclude: ["webkit", "msie7.0", "msie8.0"],	
					  	start: "<table><tbody><tr data-start=1 data-end=2><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody><tr><td>foo</td>{<td><u>bar</u></td>}<td>baz</td></tr></tbody></table>"
          },
          {   include: ["webkit"],	
					  	start: "<table><tbody><tr data-start=1 data-end=2><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody><tr><td>foo</td><td><u>[bar</u></td><td>}baz</td></tr></tbody></table>"
          },
          {   exclude: ["webkit", "msie7.0", "msie8.0"],	
					  	start: "<table><tbody><tr data-start=0 data-end=2><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody><tr>{<td><u>foo</u></td><td><u>bar</u></td>}<td>baz</td></tr></tbody></table>"
          },
          {   include: ["webkit"],	
					  	start: "<table><tbody><tr data-start=0 data-end=2><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody><tr><td><u>[foo</u></td><td><u>bar</u></td><td>}baz</td></tr></tbody></table>"
          },
          {   exclude: ["webkit", "msie7.0", "msie8.0", "msie9.0",],	
					  	start: "<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody>{<tr><td><u>foo</u></td><td><u>bar</u></td><td><u>baz</u></td></tr>}</tbody></table>"
          },
          {   include: ["webkit"],	
					  	start: "<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>",
              execResult: "<table><tbody><tr><td><u>[foo</u></td><td><u>bar</u></td><td><u>baz</u></td></tr></tbody></table>}"
          },
          {   exclude: ["webkit", "msie7.0", "msie8.0"],	
					  	start: "<table data-start=0 data-end=1><tbody><tr><td>foo<td>bar<td>baz</table>",
              execResult: "<table>{<tbody><tr><td><u>foo</u></td><td><u>bar</u></td><td><u>baz</u></td></tr></tbody>}</table>"
          },
          {   include: ["webkit"],	
					  	start: "<table data-start=0 data-end=1><tbody><tr><td>foo<td>bar<td>baz</table>",
              execResult: "{<table><tbody><tr><td><u>foo</u></td><td><u>bar</u></td><td><u>baz</u></td></tr></tbody></table>}"
          },
          {   exclude: ['msie7.0', 'msie8.0'], //adds extra whitespaces in the result
              start: "{<table><tr><td>foo<td>bar<td>baz</table>}",
              execResult: "{<table><tbody><tr><td><u>foo</u></td><td><u>bar</u></td><td><u>baz</u></td></tr></tbody></table>}"
          },
					{  	start: "foo<u>[bar]</u>baz",
              execResult: "foo[bar]baz"
          },
          {   exclude: ['mozilla', 'msie7.0', 'msie8.0'], //mozilla & ie doesn't remove the span	
					  	start: "foo<span style=\"text-decoration: underline\">[bar]</span>baz",
              execResult: "foo[bar]baz"
          },
					{  	start: "<u>foo[bar]baz</u>",
              execResult: "<u>foo</u>[bar]<u>baz</u>"
          },
					{  	start: "<u>foo[b<span style=\"color:blue\">ar]ba</span>z</u>",
              execResult: "<u>foo</u>[b<span style=\"color:rgb(0, 0, 255)\">ar]<u>ba</u></span><u>z</u>"
          },
					{  	start: "<u>foo[b<span style=\"color:blue\" id=foo>ar]ba</span>z</u>",
              execResult: "<u>foo</u>[b<span style=\"color:rgb(0, 0, 255)\" id=\"foo\">ar]<u>ba</u></span><u>z</u>"
          },
					{  	start: "<u>foo[b<span style=\"font-size:3em\">ar]ba</span>z</u>",
              execResult: "<u>foo</u>[b<span style=\"font-size:3em\">ar]<u>ba</u></span><u>z</u>"
          },
					{  	start: "<u>foo[b<i>ar]ba</i>z</u>",
              execResult: "<u>foo</u>[b<i>ar]<u>ba</u></i><u>z</u>"
          },
					{  	start: "<p style=\"text-decoration: underline\">foo[bar]baz</p>",
              execResult: "<p><u>foo</u>[bar]<u>baz</u></p>"
          },
					{  	start: "foo<s>[bar]</s>baz",
              execResult: "foo<u><s>[bar]</s></u>baz"
          },
					{  	start: "foo<span style=\"text-decoration: line-through\">[bar]</span>baz",
              execResult: "foo<u><span style=\"text-decoration:line-through\">[bar]</span></u>baz"
          },
					{  	start: "<s>foo[bar]baz</s>",
              execResult: "<s>foo<u>[bar]</u>baz</s>"
          },
					{  	start: "<s>foo[b<span style=\"color:blue\">ar]ba</span>z</s>",
              execResult: "<s>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\"><u>ar]</u>ba</span>z</s>"
          },
					{  	start: "<s>foo[b<span style=\"color:blue\" id=foo>ar]ba</span>z</s>",
              execResult: "<s>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\" id=\"foo\"><u>ar]</u>ba</span>z</s>"
          },
					{  	start: "<s>foo[b<span style=\"font-size:3em\">ar]ba</span>z</s>",
              execResult: "<s>foo<u>[b</u><span style=\"font-size:3em\"><u>ar]</u>ba</span>z</s>"
          },
					{  	start: "<s>foo[b<i>ar]ba</i>z</s>",
              execResult: "<s>foo<u>[b</u><i><u>ar]</u>ba</i>z</s>"
          },
					{  	start: "<p style=\"text-decoration: line-through\">foo[bar]baz</p>",
              execResult: "<p style=\"text-decoration:line-through\">foo<u>[bar]</u>baz</p>"
          },
					{  	start: "foo<strike>[bar]</strike>baz",
              execResult: "foo<u><strike>[bar]</strike></u>baz"
          },
					{  	start: "<strike>foo[bar]baz</strike>",
              execResult: "<strike>foo<u>[bar]</u>baz</strike>"
          },
					{  	start: "<strike>foo[b<span style=\"color:blue\">ar]ba</span>z</strike>",
              execResult: "<strike>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\"><u>ar]</u>ba</span>z</strike>"
          },
					{  	start: "<strike>foo[b<span style=\"color:blue\" id=foo>ar]ba</span>z</strike>",
              execResult: "<strike>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\" id=\"foo\"><u>ar]</u>ba</span>z</strike>"
          },
					{  	start: "<strike>foo[b<span style=\"font-size:3em\">ar]ba</span>z</strike>",
              execResult: "<strike>foo<u>[b</u><span style=\"font-size:3em\"><u>ar]</u>ba</span>z</strike>"
          },
					{  	start: "<strike>foo[b<i>ar]ba</i>z</strike>",
              execResult: "<strike>foo<u>[b</u><i><u>ar]</u>ba</i>z</strike>"
          },
					{  	start: "foo<ins>[bar]</ins>baz",
              execResult: "foo<ins>[bar]</ins>baz"
          },
					{  	start: "<ins>foo[bar]baz</ins>",
              execResult: "<ins>foo[bar]baz</ins>"
          },
					{  	start: "<ins>foo[b<span style=\"color:blue\">ar]ba</span>z</ins>",
              execResult: "<ins>foo[b<span style=\"color:rgb(0, 0, 255)\">ar]ba</span>z</ins>"
          },
					{  	start: "<ins>foo[b<span style=\"color:blue\" id=foo>ar]ba</span>z</ins>",
              execResult: "<ins>foo[b<span style=\"color:rgb(0, 0, 255)\" id=\"foo\">ar]ba</span>z</ins>"
          },
					{  	start: "<ins>foo[b<span style=\"font-size:3em\">ar]ba</span>z</ins>",
              execResult: "<ins>foo[b<span style=\"font-size:3em\">ar]ba</span>z</ins>"
          },
					{  	start: "<ins>foo[b<i>ar]ba</i>z</ins>",
              execResult: "<ins>foo[b<i>ar]ba</i>z</ins>"
          },
					{  	start: "foo<del>[bar]</del>baz",
              execResult: "foo<u><del>[bar]</del></u>baz"
          },
					{  	start: "<del>foo[bar]baz</del>",
              execResult: "<del>foo<u>[bar]</u>baz</del>"
          },
					{  	start: "<del>foo[b<span style=\"color:blue\">ar]ba</span>z</del>",
              execResult: "<del>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\"><u>ar]</u>ba</span>z</del>"
          },
					{  	start: "<del>foo[b<span style=\"color:blue\" id=foo>ar]ba</span>z</del>",
              execResult: "<del>foo<u>[b</u><span style=\"color:rgb(0, 0, 255)\" id=\"foo\"><u>ar]</u>ba</span>z</del>"
          },
					{  	start: "<del>foo[b<span style=\"font-size:3em\">ar]ba</span>z</del>",
              execResult: "<del>foo<u>[b</u><span style=\"font-size:3em\"><u>ar]</u>ba</span>z</del>"
          },
					{  	start: "<del>foo[b<i>ar]ba</i>z</del>",
              execResult: "<del>foo<u>[b</u><i><u>ar]</u>ba</i>z</del>"
          },
					{  	start: "foo<span style=\"text-decoration: underline line-through\">[bar]</span>baz",
              execResult: "foo<span style=\"text-decoration:line-through\">[bar]</span>baz"
          },
					{  	start: "foo<span style=\"text-decoration: underline line-through\">b[a]r</span>baz",
              execResult: "foo<span style=\"text-decoration:line-through\"><u>b</u>[a]<u>r</u></span>baz"
          },
          {   exclude: ['mozilla', 'msie7.0', 'msie8.0'], //mozilla & ie doesn't remove the span	
					  	start: "foo<s style=\"text-decoration: underline\">[bar]</s>baz",
              execResult: "foo[bar]baz"
          },
          {   exclude: ['mozilla', 'msie7.0', 'msie8.0'], //mozilla & ie doesn't remove the span	
					  	start: "foo<s style=\"text-decoration: underline\">b[a]r</s>baz",
              execResult: "foo<u>b</u>[a]<u>r</u>baz"
          },
					{  	start: "foo<u style=\"text-decoration: line-through\">[bar]</u>baz",
              execResult: "foo<u><u style=\"text-decoration:line-through\">[bar]</u></u>baz"
          },
					{  	start: "foo<u style=\"text-decoration: line-through\">b[a]r</u>baz",
              execResult: "foo<u style=\"text-decoration:line-through\">b<u>[a]</u>r</u>baz"
          },
					{  	start: "foo<s style=\"text-decoration: overline\">[bar]</s>baz",
              execResult: "foo<u><s style=\"text-decoration:overline\">[bar]</s></u>baz"
          },
					{  	start: "foo<s style=\"text-decoration: overline\">b[a]r</s>baz",
              execResult: "foo<s style=\"text-decoration:overline\">b<u>[a]</u>r</s>baz"
          },
					{  	start: "foo<u style=\"text-decoration: overline\">[bar]</u>baz",
              execResult: "foo<u><u style=\"text-decoration:overline\">[bar]</u></u>baz"
          },
					{  	start: "foo<u style=\"text-decoration: overline\">b[a]r</u>baz",
              execResult: "foo<u style=\"text-decoration:overline\">b<u>[a]</u>r</u>baz"
          },
					{  	start: "<p style=\"text-decoration: line-through\">foo[bar]baz</p>",
              execResult: "<p style=\"text-decoration:line-through\">foo<u>[bar]</u>baz</p>"
          },
					{  	start: "<p style=\"text-decoration: overline\">foo[bar]baz</p>",
              execResult: "<p style=\"text-decoration:overline\">foo<u>[bar]</u>baz</p>"
          },
					{  	start: "foo<span class=\"underline\">[bar]</span>baz",
              execResult: "foo<span class=\"underline\">[bar]</span>baz"
          },
					{  	start: "foo<span class=\"underline\">b[a]r</span>baz",
              execResult: "foo<span class=\"underline\">b[a]r</span>baz"
          },
					{  	start: "foo<span class=\"line-through\">[bar]</span>baz",
              execResult: "foo<u><span class=\"line-through\">[bar]</span></u>baz"
          },
					{  	start: "foo<span class=\"line-through\">b[a]r</span>baz",
              execResult: "foo<span class=\"line-through\">b<u>[a]</u>r</span>baz"
          },
					{  	start: "foo<span class=\"underline-and-line-through\">[bar]</span>baz",
              execResult: "foo<span class=\"underline-and-line-through\">[bar]</span>baz"
          },
					{  	start: "foo<span class=\"underline-and-line-through\">b[a]r</span>baz",
              execResult: "foo<span class=\"underline-and-line-through\">b[a]r</span>baz"
          },
					{  	start: "fo[o<u>b]ar</u>baz",
              execResult: "fo<u>[ob]ar</u>baz"
          },
					{  	start: "foo<u>ba[r</u>b]az",
              execResult: "foo<u>ba[rb]</u>az"
          },
					{  	start: "fo[o<u>bar</u>b]az",
              execResult: "fo<u>[obarb]</u>az"
          },
					{  	start: "foo[<u>b]ar</u>baz",
              execResult: "foo[b]<u>ar</u>baz"
          },
					{  	start: "foo<u>ba[r</u>]baz",
              execResult: "foo<u>ba</u>[r]baz"
          },
					{  	start: "foo[<u>bar</u>]baz",
              execResult: "foo[bar]baz"
          },
					{  	start: "foo<u>[bar]</u>baz",
              execResult: "foo[bar]baz"
          },
          {   exclude: ['mozilla', 'msie7.0', 'msie8.0'], //mozilla & ie doesn't remove the span	
					  	start: "fo[o<span style=text-decoration:underline>b]ar</span>baz",
              execResult: "fo<span style=\"text-decoration:underline\">[ob]ar</span>baz"
          },
					{  	start: "<ins>fo[o</ins><u>b]ar</u>",
              execResult: "<ins>fo[o</ins>b]<u>ar</u>"
          },
					{  	start: "<u>fo[o</u><ins>b]ar</ins>",
              execResult: "<u>fo</u>[o<ins>b]ar</ins>"
          }
			]
	}
	</script>
	<h1 id="qunit-header">Aloha Editor command underline tests</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<div id="qunit-fixture"></div>
	<div id="edit" style="margin:20px; border:1px solid #000000;"></div>
	<div id="logBody"></div>
	</div>
</body>
</html>
